#ifndef SYNTAX_TREE_CPP
#define SYNTAX_TREE_CPP

#include <stdio.h>
#include "syntax_tree.h"
#include "generic_table.cpp"
#include "main_container.h"
#include "errors_warnings.h"

extern MainContainer * CompilerData;

AbstractSyntaxTree::AbstractSyntaxTree() {
	RootNode = NULL;
}

AbstractSyntaxTree::~AbstractSyntaxTree() { }

void AbstractSyntaxTree::AttachParentsToChildren() {

#ifdef TRACE
	CompilerData->LogTrace->ReportEntry("AttachParentsToChildren");
#endif

	ConnectChildren(RootNode);

#ifdef TRACE
	CompilerData->LogTrace->ReportExit("AttachParentsToChildren");
#endif

}

void AbstractSyntaxTree::ConnectChildren(SyntaxTreeNode * parent) {
	// just to be sure...
	if(parent == NULL)	return;

	for(int i = 0; i < parent->Nodes->GetCount(); i++)	{
		SyntaxTreeNode * child = parent->Nodes->GetData(i);
		child->Parent = parent;
		ConnectChildren(child);
	}
}


SyntaxTreeNode::SyntaxTreeNode() {
	this->LexUnitID = -1;
	this->Nodes = new GenericTable<SyntaxTreeNode>();
	this->Production = Gr_Terminal;
	this->Parent = NULL;
}

SyntaxTreeNode::~SyntaxTreeNode() { }

const char * AbstractSyntaxTree::ConvertProductionToString(Grammar p) {
	switch(p)	{
		case Gr_Terminal: return "TERMINAL SYMBOL";
		case Gr_ProgramBody__GppFile_ProgramBody: return "<program_body> ~ <gpp_file> <program_body>";
		case Gr_ProgramBody__endOfProject: return "<program_body> ~ endOfProject";
		case Gr_GppFile__UsingDirectives_FileBody_endOfFile: return "<gpp_file> ~ <using_directives> <file_body> endOfFile";
		case Gr_UsingDirectives__UsingDirective_UsingDirectives: return "<using_directives> ~ <using_directive> <using_directives>";
		case Gr_UsingDirectives__epsilon: return "<using_directives> ~";
		case Gr_UsingDirective__using_Name_spSemiCol: return "<using_directive> ~ using <name> ;";
		case Gr_UsingDirective__using_Name_as_NAME_spSemiCol: return "<using_directive> ~ using <name> as NAME ;";
		case Gr_FileBody__MainDefinition_FileBody: return "<file_body> ~ <main_definition> <file_body>";
		case Gr_FileBody__Simulation_FileBody: return "<file_body> ~ <simulation> <file_body>";
		case Gr_FileBody__epsilon: return "<file_body> ~";
		case Gr_MainDefinition__NamespaceDefinition: return "<main_definition> ~ <namespace_definition>";
		case Gr_MainDefinition__EnumDefinition: return "<main_definition> ~ <enum_definition>";
		case Gr_MainDefinition__ClassDefinition: return "<main_definition> ~ <class_definition>";
		case Gr_MainDefinition__ModelDefinition: return "<main_definition> ~ <model_definition>";
		case Gr_MainDefinition__MethodDefinition: return "<main_definition> ~ <method_definition>";
		case Gr_MainDefinition__FieldDefinition: return "<main_definition> ~ <field_definition>";
		case Gr_MainDefinition__PropertyDefinition: return "<main_definition> ~ <property_definition>";
		case Gr_NamespaceDefinition__namespace_Name_spLCBrac_UsingDirectives_FileBody_spRCBrac: return "<namespace_definition> ~ namespace <name> { <using_directives> <file_body> }";
		case Gr_DataType__Name_TemplateUse: return "<data_type> ~ <name> <template_use>";
		case Gr_DataType__Name: return "<data_type> ~ <name>";
		case Gr_DataType__int: return "<data_type> ~ int";
		case Gr_DataType__float: return "<data_type> ~ float";
		case Gr_DataType__bool: return "<data_type> ~ bool";
		case Gr_DataType__state: return "<data_type> ~ state";
		case Gr_DataType__time: return "<data_type> ~ time";
		case Gr_DataType__void: return "<data_type> ~ void";
		case Gr_DataType__Facility: return "<data_type> ~ Facility";
		case Gr_DataType__Storage: return "<data_type> ~ Storage";
		case Gr_DataType__Queue: return "<data_type> ~ Queue";
		case Gr_DataType__ADTable: return "<data_type> ~ ADTable";
		case Gr_DataType__Group: return "<data_type> ~ Group";
		case Gr_DataType__OutputStream: return "<data_type> ~ OutputStream";
		case Gr_EnumDefinition__enum_NAME_spLCBrac_EnumNames_spRCBrac: return "<enum_definition> ~ enum NAME { <enum_names> }";
		case Gr_EnumNames__NAME_EnumNamesAdd: return "<enum_names> ~ NAME <enum_names_add>";
		case Gr_NameCommaAdd__spComma_NAME: return "<name_comma_add> ~ , NAME";
		case Gr_EnumNamesAdd__NameCommaAdd_EnumNamesAdd: return "<enum_names_add> ~ <name_comma_add> <enum_names_add>";
		case Gr_EnumNamesAdd__epsilon: return "<enum_names_add> ~";
		case Gr_ClassDefinition__ClassMods_TemplateDefinition_class_NAME_ClassInherit_spLCBrac_UsingDirectives_ClassBodyAdd_spRCBrac: return "<class_definition> ~ <class_mods> <template_definition> class NAME <class_inherit> { <using_directives> <class_body_add> }";
		case Gr_ClassMods__ClassMod_ClassMods: return "<class_mods> ~ <class_mod> <class_mods>";
		case Gr_ClassMods__epsilon: return "<class_mods> ~";
		case Gr_ClassMod__abstract: return "<class_mod> ~ abstract";
		case Gr_ClassMod__public: return "<class_mod> ~ public";
		case Gr_ClassMod__private: return "<class_mod> ~ private";
		case Gr_ClassMod__protected: return "<class_mod> ~ protected";
		case Gr_ClassMod__final: return "<class_mod> ~ final";
		case Gr_TemplateDefinition__template_TemplateUse: return "<template_definition> ~ template <template_use>";
		case Gr_TemplateDefinition__epsilon: return "<template_definition> ~";
		case Gr_TemplateUse__opLess_TemplatesList_opGreat: return "<template_use> ~ < <templates_list> >";
		case Gr_TemplatesList__NAME_TemplatesListAdd: return "<templates_list> ~ NAME <templates_list_add>";
		case Gr_TemplatesListAdd__NameCommaAdd_TemplatesListAdd: return "<templates_list_add> ~ <name_comma_add> <templates_list_add>";
		case Gr_TemplatesListAdd__epsilon: return "<templates_list_add> ~";
		case Gr_ClassInherit__spColon_ClassInheritName: return "<class_inherit> ~ : <class_inherit_name>";
		case Gr_ClassInherit__epsilon: return "<class_inherit> ~";
		case Gr_ClassInheritName__Name_TemplateUse: return "<class_inherit_name> ~ <name> <template_use>";
		case Gr_ClassInheritName__Name: return "<class_inherit_name> ~ <name>";
		case Gr_ClassBodyAdd__ClassBody_ClassBodyAdd: return "<class_body_add> ~ <class_body> <class_body_add>";
		case Gr_ClassBodyAdd__epsilon: return "<class_body_add> ~";
		case Gr_ClassBody__ConstructorDefinition: return "<class_body> ~ <constructor_definition>";
		case Gr_ClassBody__FieldDefinition: return "<class_body> ~ <field_definition>";
		case Gr_ClassBody__MethodDefinition: return "<class_body> ~ <method_definition>";
		case Gr_ClassBody__PropertyDefinition: return "<class_body> ~ <property_definition>";
		case Gr_ClassBody__EnumDefinition: return "<class_body> ~ <enum_definition>";
		case Gr_ClassBody__ClassDefinition: return "<class_body> ~ <class_definition>";
		case Gr_ConstructorDefinition__ConstrMod_NAME_spLPar_Parameters_spRPar_ConstrInherit_ConstrBody: return "<constructor_definition> ~ <constr_mod> NAME ( <parameters> ) <constr_inherit> <constr_body>";
		case Gr_ConstrMod__public: return "<constr_mod> ~ public";
		case Gr_ConstrMod__private: return "<constr_mod> ~ private";
		case Gr_ConstrMod__protected: return "<constr_mod> ~ protected";
		case Gr_ConstrMod__epsilon: return "<constr_mod> ~";
		case Gr_ConstrInherit__spColon_Name_spLPar_Arguments_spRPar: return "<constr_inherit> ~ : <name> ( <arguments> )";
		case Gr_ConstrInherit__epsilon: return "<constr_inherit> ~";
		case Gr_ConstrBody__spSemiCol: return "<constr_body> ~ ;";
		case Gr_ConstrBody__spLCBrac_MethodBody_spRCBrac: return "<constr_body> ~ { <method_body> }";
		case Gr_FieldDefinition__FieldMods_TracePart_DataType_FieldNames_spSemiCol: return "<field_definition> ~ <field_mods> <trace_part> <data_type> <field_names> ;";
		case Gr_FieldMods__FieldMod_FieldMods: return "<field_mods> ~ <field_mod> <field_mods>";
		case Gr_FieldMods__epsilon: return "<field_mods> ~";
		case Gr_FieldMod__const: return "<field_mod> ~ const";
		case Gr_FieldMod__public: return "<field_mod> ~ public";
		case Gr_FieldMod__private: return "<field_mod> ~ private";
		case Gr_FieldMod__protected: return "<field_mod> ~ protected";
		case Gr_FieldMod__static: return "<field_mod> ~ static";
		case Gr_FieldNames__FieldName_Equals_FieldNamesAdd: return "<field_names> ~ <field_name> <equals> <field_names_add>";
		case Gr_FieldName__NAME_ArrayDefinitions: return "<field_name> ~ NAME <array_definitions>";
		case Gr_FieldNamesAdd__spComma_FieldNames: return "<field_names_add> ~ , <field_names>";
		case Gr_FieldNamesAdd__epsilon: return "<field_names_add> ~";
		case Gr_Equals__opAssign_Expression: return "<equals> ~ = <expression>";
		case Gr_Equals__epsilon: return "<equals> ~";
		case Gr_ArrayDefinitions__ArrayDefinition_ArrayDefinitions: return "<array_definitions> ~ <array_definition> <array_definitions>";
		case Gr_ArrayDefinitions__epsilon: return "<array_definitions> ~";
		case Gr_ArrayDefinition__spLSBrac_spRSBrac: return "<array_definition> ~ [ ]";
		case Gr_PropertyDefinition__PropertyMods_DataType_PropertyName: return "<property_definition> ~ <property_mods> <data_type> <property_name>";
		case Gr_PropertyMods__PropertyMod_PropertyMods: return "<property_mods> ~ <property_mod> <property_mods>";
		case Gr_PropertyMods__epsilon: return "<property_mods> ~";
		case Gr_PropertyMod__public: return "<property_mod> ~ public";
		case Gr_PropertyMod__protected: return "<property_mod> ~ protected";
		case Gr_PropertyMod__private: return "<property_mod> ~ private";
		case Gr_PropertyMod__static: return "<property_mod> ~ static";
		case Gr_PropertyMod__abstract: return "<property_mod> ~ abstract";
		case Gr_PropertyMod__override: return "<property_mod> ~ override";
		case Gr_PropertyMod__virtual: return "<property_mod> ~ virtual";
		case Gr_PropertyMod__final: return "<property_mod> ~ final";
		case Gr_PropertyName__NAME_PropArrayDefs_PropertyBody: return "<property_name> ~ NAME <prop_array_defs> <property_body>";
		case Gr_PropArrayDefs__PropArrayDef_PropArrayDefs: return "<prop_array_defs> ~ <prop_array_def> <prop_array_defs>";
		case Gr_PropArrayDefs__epsilon: return "<prop_array_defs> ~";
		case Gr_PropArrayDef__spLSBrac_int_NAME_spRSBrac: return "<prop_array_def> ~ [ int NAME ]";
		case Gr_PropertyBody__spLCBrac_PropertyRead_PropertyWrite_spRCBrac: return "<property_body> ~ { <property_read> <property_write> }";
		case Gr_PropertyBody__spLCBrac_PropertyWrite_PropertyRead_spRCBrac: return "<property_body> ~ { <property_write> <property_read> }";
		case Gr_PropertyRead__read_spLCBrac_MethodBody_spRCBrac: return "<property_read> ~ read { <method_body> }";
		case Gr_PropertyRead__epsilon: return "<property_read> ~";
		case Gr_PropertyWrite__write_spLCBrac_MethodBody_spRCBrac: return "<property_write> ~ write { <method_body> }";
		case Gr_PropertyWrite__epsilon: return "<property_write> ~";
		case Gr_MethodDefinition__MethodMods_StartProcess_DataType_NAME_spLPar_Parameters_spRPar_MethodBodyDecl: return "<method_definition> ~ <method_mods> <start_process> <data_type> NAME ( <parameters> ) <method_body_decl>";
		case Gr_MethodDefinition__MethodMods_numeric_NumericMod_DataType_NAME_spLPar_Parameters_spRPar_spLCBrac_InfBegin_ValuePairs_InfEnd_spRCBrac: return "<method_definition> ~ <method_mods> numeric <numeric_mod> <data_type> NAME ( <parameters> ) { <inf_begin> <value_pairs> <inf_end> }";
		case Gr_MethodMods__MethodMod_MethodMods: return "<method_mods> ~ <method_mod> <method_mods>";
		case Gr_MethodMods__epsilon: return "<method_mods> ~";
		case Gr_MethodMod__abstract: return "<method_mod> ~ abstract";
		case Gr_MethodMod__virtual: return "<method_mod> ~ virtual";
		case Gr_MethodMod__public: return "<method_mod> ~ public";
		case Gr_MethodMod__private: return "<method_mod> ~ private";
		case Gr_MethodMod__protected: return "<method_mod> ~ protected";
		case Gr_MethodMod__override: return "<method_mod> ~ override";
		case Gr_MethodMod__static: return "<method_mod> ~ static";
		case Gr_MethodMod__final: return "<method_mod> ~ final";
		case Gr_StartProcess__start_process: return "<start_process> ~ start process";
		case Gr_StartProcess__process: return "<start_process> ~ process";
		case Gr_StartProcess__epsilon: return "<start_process> ~";
		case Gr_MethodBodyDecl__spSemiCol: return "<method_body_decl> ~ ;";
		case Gr_MethodBodyDecl__spLCBrac_MethodBody_spRCBrac: return "<method_body_decl> ~ { <method_body> }";
		case Gr_MethodBody__LabelMethodStatement_MethodBody: return "<method_body> ~ <label_method_statement> <method_body>";
		case Gr_MethodBody__epsilon: return "<method_body> ~";
		case Gr_LabelMethodStatement__MethodLabels_MethodStatement: return "<label_method_statement> ~ <method_labels> <method_statement>";
		case Gr_MethodLabels__Label_MethodLabels: return "<method_labels> ~ <label> <method_labels>";
		case Gr_MethodLabels__epsilon: return "<method_labels> ~";
		case Gr_Label__NAME_spColon: return "<label> ~ NAME :";
		case Gr_MethodStatement__VariableDefinition: return "<method_statement> ~ <variable_definition>";
		case Gr_MethodStatement__Assignment: return "<method_statement> ~ <assignment>";
		case Gr_MethodStatement__MethodCall: return "<method_statement> ~ <method_call>";
		case Gr_MethodStatement__IfStatement: return "<method_statement> ~ <if_statement>";
		case Gr_MethodStatement__WhileStatement: return "<method_statement> ~ <while_statement>";
		case Gr_MethodStatement__ForStatement: return "<method_statement> ~ <for_statement>";
		case Gr_MethodStatement__DowhileStatement: return "<method_statement> ~ <dowhile_statement>";
		case Gr_MethodStatement__SwitchCaseStatement: return "<method_statement> ~ <switch_case_statement>";
		case Gr_MethodStatement__BreakStatement: return "<method_statement> ~ <break_statement>";
		case Gr_MethodStatement__ContinueStatement: return "<method_statement> ~ <continue_statement>";
		case Gr_MethodStatement__ReturnStatement: return "<method_statement> ~ <return_statement>";
		case Gr_MethodStatement__GotoStatement: return "<method_statement> ~ <goto_statement>";
		case Gr_MethodStatement__StartStatement: return "<method_statement> ~ <start_statement>";
		case Gr_MethodStatement__StopStatement: return "<method_statement> ~ <stop_statement>";
		case Gr_MethodStatement__AssignmentDerivation: return "<method_statement> ~ <assignment_derivation>";
		case Gr_MethodStatement__BlockStatement: return "<method_statement> ~ <block_statement>";
		case Gr_MethodStatement__epsilon: return "<method_statement> ~";
		case Gr_Parameters__Parameter_ParametersAdd: return "<parameters> ~ <parameter> <parameters_add>";
		case Gr_Parameters__epsilon: return "<parameters> ~";
		case Gr_ParameterCommaAdd__spComma_Parameter: return "<parameter_comma_add> ~ , <parameter>";
		case Gr_ParametersAdd__ParameterCommaAdd_ParametersAdd: return "<parameters_add> ~ <parameter_comma_add> <parameters_add>";
		case Gr_ParametersAdd__epsilon: return "<parameters_add> ~";
		case Gr_Parameter__DataType_NAME_ArrayDefinitions: return "<parameter> ~ <data_type> NAME <array_definitions>";
		case Gr_Arguments__Expression_ArgumentsAdd: return "<arguments> ~ <expression> <arguments_add>";
		case Gr_Arguments__epsilon: return "<arguments> ~";
		case Gr_ArgumentCommaAdd__spComma_Expression: return "<argument_comma_add> ~ , <expression>";
		case Gr_ArgumentsAdd__ArgumentCommaAdd_ArgumentsAdd: return "<arguments_add> ~ <argument_comma_add> <arguments_add>";
		case Gr_ArgumentsAdd__epsilon: return "<arguments_add> ~";
		case Gr_VariableDefinition__TracePart_DataType_FieldNames_spSemiCol: return "<variable_definition> ~ <trace_part> <data_type> <field_names> ;";
		case Gr_TracePart__trace_NumericMod_spLPar_Arguments_spRPar: return "<trace_part> ~ trace <numeric_mod> ( <arguments> )";
		case Gr_TracePart__trace_NumericMod: return "<trace_part> ~ trace <numeric_mod>";
		case Gr_TracePart__epsilon: return "<trace_part> ~";
		case Gr_Assignment__VariableValue_opAssign_Expression_spSemiCol: return "<assignment> ~ <variable_value> = <expression> ;";
		case Gr_MethodCall__NAME_spLPar_Arguments_spRPar_spSemiCol: return "<method_call> ~ NAME ( <arguments> ) ;";
		case Gr_MethodCall__VariableValue_spPer_NAME_spLPar_Arguments_spRPar_spSemiCol: return "<method_call> ~ <variable_value> . NAME ( <arguments> ) ;";
		case Gr_IfStatement__if_spLPar_Expression_spRPar_BlockStatement_ElsePart: return "<if_statement> ~ if ( <expression> ) <block_statement> <else_part>";
		case Gr_BlockStatement__spLCBrac_MethodBody_spRCBrac: return "<block_statement> ~ { <method_body> }";
		case Gr_ElsePart__else_BlockStatement: return "<else_part> ~ else <block_statement>";
		case Gr_ElsePart__epsilon: return "<else_part> ~";
		case Gr_SwitchCaseStatement__switch_spLPar_Expression_spRPar_spLCBrac_SwitchCaseCases_SwitchCaseDefault_spRCBrac: return "<switch_case_statement> ~ switch ( <expression> ) { <switch_case_cases> <switch_case_default> }";
		case Gr_SwitchCaseCases__SwitchCaseCase_SwitchCaseCases: return "<switch_case_cases> ~ <switch_case_case> <switch_case_cases>";
		case Gr_SwitchCaseCases__epsilon: return "<switch_case_cases> ~";
		case Gr_SwitchCaseCase__case_Expression_spColon_BlockStatement: return "<switch_case_case> ~ case <expression> : <block_statement>";
		case Gr_SwitchCaseDefault__default_spColon_BlockStatement: return "<switch_case_default> ~ default : <block_statement>";
		case Gr_SwitchCaseDefault__epsilon: return "<switch_case_default> ~";
		case Gr_WhileStatement__while_spLPar_Expression_spRPar_BlockStatement: return "<while_statement> ~ while ( <expression> ) <block_statement>";
		case Gr_DowhileStatement__do_BlockStatement_while_spLPar_Expression_spRPar_spSemiCol: return "<dowhile_statement> ~ do <block_statement> while ( <expression> ) ;";
		case Gr_ForStatement__for_spLPar_SimpleStatement_spSemiCol_Expression_spSemiCol_SimpleStatement_spRPar_BlockStatement: return "<for_statement> ~ for ( <simple_statement> ; <expression> ; <simple_statement> ) <block_statement>";
		case Gr_SimpleStatement__DataType_FieldNames: return "<simple_statement> ~ <data_type> <field_names>";
		case Gr_SimpleStatement__VariableValue_opAssign_Expression: return "<simple_statement> ~ <variable_value> = <expression>";
		case Gr_SimpleStatement__NAME_spLPar_Arguments_spRPar: return "<simple_statement> ~ NAME ( <arguments> )";
		case Gr_SimpleStatement__VariableValue_spPer_NAME_spLPar_Arguments_spRPar: return "<simple_statement> ~ <variable_value> . NAME ( <arguments> )";
		case Gr_BreakStatement__break_spSemiCol: return "<break_statement> ~ break ;";
		case Gr_ContinueStatement__continue_spSemiCol: return "<continue_statement> ~ continue ;";
		case Gr_GotoStatement__goto_NAME_spSemiCol: return "<goto_statement> ~ goto NAME ;";
		case Gr_ReturnStatement__return_Expression_spSemiCol: return "<return_statement> ~ return <expression> ;";
		case Gr_ReturnStatement__return_spSemiCol: return "<return_statement> ~ return ;";
		case Gr_StartStatement__start_Name_spLPar_Arguments_spRPar_with_StartAssignments_spSemiCol: return "<start_statement> ~ start <name> ( <arguments> ) with <start_assignments> ;";
		case Gr_StartStatement__start_Name_spLPar_Arguments_spRPar_spSemiCol: return "<start_statement> ~ start <name> ( <arguments> ) ;";
		case Gr_StartAssignments__StartAssignment_StartAssignmentAdd: return "<start_assignments> ~ <start_assignment> <start_assignment_add>";
		case Gr_StartAssignmentAdd__StartAssignmentCommaAdd_StartAssignmentAdd: return "<start_assignment_add> ~ <start_assignment_comma_add> <start_assignment_add>";
		case Gr_StartAssignmentAdd__epsilon: return "<start_assignment_add> ~";
		case Gr_StartAssignmentCommaAdd__spComma_StartAssignment: return "<start_assignment_comma_add> ~ , <start_assignment>";
		case Gr_StartAssignment__NAME_opAssign_Expression: return "<start_assignment> ~ NAME = <expression>";
		case Gr_StopStatement__stop_Name_spSemiCol: return "<stop_statement> ~ stop <name> ;";
		case Gr_AssignmentDerivation__derivation_VariableValue_opAssign_Expression_spSemiCol: return "<assignment_derivation> ~ derivation <variable_value> = <expression> ;";
		case Gr_NumericMod__discrete: return "<numeric_mod> ~ discrete";
		case Gr_NumericMod__continuous: return "<numeric_mod> ~ continuous";
		case Gr_InfBegin__opSub_INF_spSemiCol: return "<inf_begin> ~ - INF ;";
		case Gr_InfBegin__epsilon: return "<inf_begin> ~";
		case Gr_InfEnd__spSemiCol_opAdd_INF: return "<inf_end> ~ ; + INF";
		case Gr_InfEnd__epsilon: return "<inf_end> ~";
		case Gr_ValuePairs__ValuePair_ValuePairsAdds: return "<value_pairs> ~ <value_pair> <value_pairs_adds>";
		case Gr_ValuePairs__epsilon: return "<value_pairs> ~";
		case Gr_ValuePairsAdds__epsilon: return "<value_pairs_adds> ~";
		case Gr_ValuePairsAdds__ValuePairAdd_ValuePairsAdds: return "<value_pairs_adds> ~ <value_pair_add> <value_pairs_adds>";
		case Gr_ValuePairAdd__spSemiCol_ValuePair: return "<value_pair_add> ~ ; <value_pair>";
		case Gr_ValuePair__SignValue_LITERAL_spArrow_SignValue_LITERAL: return "<value_pair> ~ <sign_value> LITERAL -> <sign_value> LITERAL";
		case Gr_SignValue__opAdd: return "<sign_value> ~ +";
		case Gr_SignValue__opSub: return "<sign_value> ~ -";
		case Gr_SignValue__epsilon: return "<sign_value> ~";
		case Gr_ModelDefinition__ModelMod_model_Name_spLPar_Parameters_spRPar_ModelDefinitionIn_ModelDefinitionOut_spLCBrac_ModelBody_spRCBrac: return "<model_definition> ~ <model_mod> model <name> ( <parameters> ) <model_definition_in> <model_definition_out> { <model_body> }";
		case Gr_ModelDefinitionIn__in_spLPar_LabelList_spRPar: return "<model_definition_in> ~ in ( <label_list> )";
		case Gr_ModelDefinitionIn__epsilon: return "<model_definition_in> ~";
		case Gr_ModelDefinitionOut__out_spLPar_LabelList_spRPar: return "<model_definition_out> ~ out ( <label_list> )";
		case Gr_ModelDefinitionOut__epsilon: return "<model_definition_out> ~";
		case Gr_LabelList__epsilon: return "<label_list> ~";
		case Gr_LabelList__default_Labels: return "<label_list> ~ default <labels>";
		case Gr_LabelList__NAME_Labels: return "<label_list> ~ NAME <labels>";
		case Gr_Labels__CommaLabel_Labels: return "<labels> ~ <comma_label> <labels>";
		case Gr_Labels__epsilon: return "<labels> ~";
		case Gr_CommaLabel__spComma_NAME: return "<comma_label> ~ , NAME";
		case Gr_ModelMod__public: return "<model_mod> ~ public";
		case Gr_ModelMod__private: return "<model_mod> ~ private";
		case Gr_ModelMod__epsilon: return "<model_mod> ~";
		case Gr_ModelBody__UsingDirectives_ModelDefine_ModelStructure: return "<model_body> ~ <using_directives> <model_define> <model_structure>";
		case Gr_ModelDefine__define_spLCBrac_DefineBodyStatements_spRCBrac: return "<model_define> ~ define { <define_body_statements> }";
		case Gr_ModelDefine__epsilon: return "<model_define> ~";
		case Gr_DefineBodyStatements__DefineBodyStatement_DefineBodyStatements: return "<define_body_statements> ~ <define_body_statement> <define_body_statements>";
		case Gr_DefineBodyStatements__epsilon: return "<define_body_statements> ~";
		case Gr_DefineBodyStatement__FieldDefinition: return "<define_body_statement> ~ <field_definition>";
		case Gr_DefineBodyStatement__PropertyDefinition: return "<define_body_statement> ~ <property_definition>";
		case Gr_DefineBodyStatement__MethodDefinition: return "<define_body_statement> ~ <method_definition>";
		case Gr_DefineBodyStatement__EnumDefinition: return "<define_body_statement> ~ <enum_definition>";
		case Gr_LabelGpssBlock__BlockLabels_GpssBlock: return "<label_gpss_block> ~ <block_labels> <gpss_block>";
		case Gr_ModelStructure__LabelGpssBlock_ModelStructure: return "<model_structure> ~ <label_gpss_block> <model_structure>";
		case Gr_ModelStructure__epsilon: return "<model_structure> ~";
		case Gr_BlockLabels__epsilon: return "<block_labels> ~";
		case Gr_BlockLabels__BlockLabel_BlockLabels: return "<block_labels> ~ <block_label> <block_labels>";
		case Gr_BlockLabel__NAME_spColon: return "<block_label> ~ NAME :";
		case Gr_BlockLabel__NAME_spPer_NAME_spColon: return "<block_label> ~ NAME . NAME :";
		case Gr_GpssBlock__GenerateBlock: return "<gpss_block> ~ <generate_block>";
		case Gr_GpssBlock__TerminateBlock: return "<gpss_block> ~ <terminate_block>";
		case Gr_GpssBlock__AdvanceBlock: return "<gpss_block> ~ <advance_block>";
		case Gr_GpssBlock__EnterBlock: return "<gpss_block> ~ <enter_block>";
		case Gr_GpssBlock__LeaveBlock: return "<gpss_block> ~ <leave_block>";
		case Gr_GpssBlock__SeizeBlock: return "<gpss_block> ~ <seize_block>";
		case Gr_GpssBlock__ReleaseBlock: return "<gpss_block> ~ <release_block>";
		case Gr_GpssBlock__InqueueBlock: return "<gpss_block> ~ <inqueue_block>";
		case Gr_GpssBlock__OutqueueBlock: return "<gpss_block> ~ <outqueue_block>";
		case Gr_GpssBlock__ArriveBlock: return "<gpss_block> ~ <arrive_block>";
		case Gr_GpssBlock__DepartBlock: return "<gpss_block> ~ <depart_block>";
		case Gr_GpssBlock__ModelInstanceBlock: return "<gpss_block> ~ <model_instance_block>";
		case Gr_GpssBlock__GotoBlock: return "<gpss_block> ~ <goto_block>";
		case Gr_GpssBlock__IfBlock: return "<gpss_block> ~ <if_block>";
		case Gr_GpssBlock__WaitBlock: return "<gpss_block> ~ <wait_block>";
		case Gr_GpssBlock__JoinGroupBlock: return "<gpss_block> ~ <join_group_block>";
		case Gr_GpssBlock__LeaveGroupBlock: return "<gpss_block> ~ <leave_group_block>";
		case Gr_GpssBlock__CreateBlock: return "<gpss_block> ~ <create_block>";
		case Gr_GpssBlock__SplitBlock: return "<gpss_block> ~ <split_block>";
		case Gr_GpssBlock__GatherBlock: return "<gpss_block> ~ <gather_block>";
		case Gr_GpssBlock__ExecuteBlock: return "<gpss_block> ~ <execute_block>";
		case Gr_GenerateBlock__generate_UptoExpression_GenerateTransactions_AfterExpression_EveryExpression_spSemiCol: return "<generate_block> ~ generate <upto_expression> <generate_transactions> <after_expression> <every_expression> ;";
		case Gr_UptoExpression__upto_Expression: return "<upto_expression> ~ upto <expression>";
		case Gr_UptoExpression__epsilon: return "<upto_expression> ~";
		case Gr_GenerateTransactions__Name_spLPar_TransList_spRPar: return "<generate_transactions> ~ <name> ( <trans_list> )";
		case Gr_GenerateTransactions__Name: return "<generate_transactions> ~ <name>";
		case Gr_GenerateTransactions__epsilon: return "<generate_transactions> ~";
		case Gr_AfterExpression__after_Expression: return "<after_expression> ~ after <expression>";
		case Gr_AfterExpression__epsilon: return "<after_expression> ~";
		case Gr_EveryExpression__every_Expression_PlusMinusExpression: return "<every_expression> ~ every <expression> <plus_minus_expression>";
		case Gr_EveryExpression__epsilon: return "<every_expression> ~";
		case Gr_PlusMinusExpression__spPlusMinus_Expression: return "<plus_minus_expression> ~ +- <expression>";
		case Gr_PlusMinusExpression__epsilon: return "<plus_minus_expression> ~";
		case Gr_TransList__Name_spColon_Expression_TransListAdds: return "<trans_list> ~ <name> : <expression> <trans_list_adds>";
		case Gr_TransListAdds__TransListAdd_TransListAdds: return "<trans_list_adds> ~ <trans_list_add> <trans_list_adds>";
		case Gr_TransListAdds__epsilon: return "<trans_list_adds> ~";
		case Gr_TransListAdd__spSemiCol_Name_spColon_Expression: return "<trans_list_add> ~ ; <name> : <expression>";
		case Gr_TerminateBlock__terminate_Expression_spSemiCol: return "<terminate_block> ~ terminate <expression> ;";
		case Gr_TerminateBlock__terminate_spSemiCol: return "<terminate_block> ~ terminate ;";
		case Gr_AdvanceBlock__advance_Expression_PlusMinusExpression_spSemiCol: return "<advance_block> ~ advance <expression> <plus_minus_expression> ;";
		case Gr_EnterBlock__enter_UnitsInExpression_Expression_FormingExpression_spSemiCol: return "<enter_block> ~ enter <units_in_expression> <expression> <forming_expression> ;";
		case Gr_UnitsInExpression__Expression_units_in: return "<units_in_expression> ~ <expression> units in";
		case Gr_UnitsInExpression__epsilon: return "<units_in_expression> ~";
		case Gr_FormingExpression__forming_Expression: return "<forming_expression> ~ forming <expression>";
		case Gr_FormingExpression__epsilon: return "<forming_expression> ~";
		case Gr_LeaveBlock__leave_UnitsFromExpression_Expression_spSemiCol: return "<leave_block> ~ leave <units_from_expression> <expression> ;";
		case Gr_UnitsFromExpression__Expression_units_from: return "<units_from_expression> ~ <expression> units from";
		case Gr_UnitsFromExpression__epsilon: return "<units_from_expression> ~";
		case Gr_SeizeBlock__seize_Expression_FormingExpression_spSemiCol: return "<seize_block> ~ seize <expression> <forming_expression> ;";
		case Gr_ReleaseBlock__release_Expression_spSemiCol: return "<release_block> ~ release <expression> ;";
		case Gr_InqueueBlock__inqueue_Expression_spSemiCol: return "<inqueue_block> ~ inqueue <expression> ;";
		case Gr_OutqueueBlock__outqueue_Expression_spSemiCol: return "<outqueue_block> ~ outqueue <expression> ;";
		case Gr_ArriveBlock__arrive_Expression_spSemiCol: return "<arrive_block> ~ arrive <expression> ;";
		case Gr_DepartBlock__depart_Expression_spSemiCol: return "<depart_block> ~ depart <expression> ;";
		case Gr_ModelInstanceBlock__model_Name_spLPar_Arguments_spRPar_spSemiCol: return "<model_instance_block> ~ model <name> ( <arguments> ) ;";
		case Gr_ModelInstanceBlock__Name_spLPar_Arguments_spRPar_spSemiCol: return "<model_instance_block> ~ <name> ( <arguments> ) ;";
		case Gr_GotoBlock__goto_Name_spSemiCol: return "<goto_block> ~ goto <name> ;";
		case Gr_IfBlock__if_spLPar_Expression_spRPar_spLCBrac_ModelStructure_spRCBrac_ElseStructure: return "<if_block> ~ if ( <expression> ) { <model_structure> } <else_structure>";
		case Gr_WaitBlock__wait_OnSensitivityList_FormingExpression_WhileUntil_spLPar_Expression_spRPar_ThenStructure_ElseStructure_Timeout_spSemiCol: return "<wait_block> ~ wait <on_sensitivity_list> <forming_expression> <while_until> ( <expression> ) <then_structure> <else_structure> <timeout> ;";
		case Gr_OnSensitivityList__on_SensitivityList: return "<on_sensitivity_list> ~ on <sensitivity_list>";
		case Gr_OnSensitivityList__epsilon: return "<on_sensitivity_list> ~";
		case Gr_WhileUntil__while: return "<while_until> ~ while";
		case Gr_WhileUntil__until: return "<while_until> ~ until";
		case Gr_ThenStructure__then_spLCBrac_ModelStructure_spRCBrac: return "<then_structure> ~ then { <model_structure> }";
		case Gr_ThenStructure__epsilon: return "<then_structure> ~";
		case Gr_ElseStructure__else_spLCBrac_ModelStructure_spRCBrac: return "<else_structure> ~ else { <model_structure> }";
		case Gr_ElseStructure__epsilon: return "<else_structure> ~";
		case Gr_Timeout__timeout_Expression: return "<timeout> ~ timeout <expression>";
		case Gr_Timeout__timeout_Expression_spLCBrac_ModelStructure_spRCBrac: return "<timeout> ~ timeout <expression> { <model_structure> }";
		case Gr_Timeout__epsilon: return "<timeout> ~";
		case Gr_SensitivityList__Name_SensitivityListAdds: return "<sensitivity_list> ~ <name> <sensitivity_list_adds>";
		case Gr_SensitivityListAdds__SensitivityListAdd_SensitivityListAdds: return "<sensitivity_list_adds> ~ <sensitivity_list_add> <sensitivity_list_adds>";
		case Gr_SensitivityListAdds__epsilon: return "<sensitivity_list_adds> ~";
		case Gr_SensitivityListAdd__spComma_Name: return "<sensitivity_list_add> ~ , <name>";
		case Gr_JoinGroupBlock__join_group_Expression_spSemiCol: return "<join_group_block> ~ join group <expression> ;";
		case Gr_LeaveGroupBlock__leave_group_Expression_spSemiCol: return "<leave_group_block> ~ leave group <expression> ;";
		case Gr_CreateBlock__create_UptoExpression_GenerateTransactions_AfterExpression_EveryExpression_SendTo_spSemiCol: return "<create_block> ~ create <upto_expression> <generate_transactions> <after_expression> <every_expression> <send_to> ;";
		case Gr_SendTo__send_to_Name: return "<send_to> ~ send to <name>";
		case Gr_SendTo__epsilon: return "<send_to> ~";
		case Gr_SplitBlock__split_IntoExpression_SendTo_spSemiCol: return "<split_block> ~ split <into_expression> <send_to> ;";
		case Gr_IntoExpression__into_Expression: return "<into_expression> ~ into <expression>";
		case Gr_IntoExpression__epsilon: return "<into_expression> ~";
		case Gr_GatherBlock__gather_AndDestroy_Expression_spSemiCol: return "<gather_block> ~ gather <and_destroy> <expression> ;";
		case Gr_GatherBlock__gather_AndDestroy_spSemiCol: return "<gather_block> ~ gather <and_destroy> ;";
		case Gr_AndDestroy__and_destroy: return "<and_destroy> ~ and destroy";
		case Gr_AndDestroy__epsilon: return "<and_destroy> ~";
		case Gr_ExecuteBlock__execute_spLCBrac_MethodBody_spRCBrac: return "<execute_block> ~ execute { <method_body> }";
		case Gr_ExecuteBlock__exec_spLCBrac_MethodBody_spRCBrac: return "<execute_block> ~ exec { <method_body> }";
		case Gr_Simulation__simulation_NAME_spLCBrac_SimulationBody_spRCBrac: return "<simulation> ~ simulation NAME { <simulation_body> }";
		case Gr_SimulationBody__SimulationStmt_SimulationBody: return "<simulation_body> ~ <simulation_stmt> <simulation_body>";
		case Gr_SimulationBody__epsilon: return "<simulation_body> ~";
		case Gr_SimulationStmt__SimConfiguration: return "<simulation_stmt> ~ <sim_configuration>";
		case Gr_SimulationStmt__SimRun: return "<simulation_stmt> ~ <sim_run>";
		case Gr_SimulationStmt__SimClear: return "<simulation_stmt> ~ <sim_clear>";
		case Gr_SimulationStmt__SimReset: return "<simulation_stmt> ~ <sim_reset>";
		case Gr_SimConfiguration__configuration_Name_spLPar_Arguments_spRPar_spSemiCol: return "<sim_configuration> ~ configuration <name> ( <arguments> ) ;";
		case Gr_SimRun__run_Expression_simulations_UptoExpression_spSemiCol: return "<sim_run> ~ run <expression> simulations <upto_expression> ;";
		case Gr_SimRun__run_UptoExpression_spSemiCol: return "<sim_run> ~ run <upto_expression> ;";
		case Gr_SimClear__clear_spSemiCol: return "<sim_clear> ~ clear ;";
		case Gr_SimReset__reset_spSemiCol: return "<sim_reset> ~ reset ;";
		case Gr_Expression__Expression2_ExpressionAdds: return "<expression> ~ <expression2> <expression_adds>";
		case Gr_ExpressionAdds__ExpressionAdd_ExpressionAdds: return "<expression_adds> ~ <expression_add> <expression_adds>";
		case Gr_ExpressionAdds__epsilon: return "<expression_adds> ~";
		case Gr_ExpressionAdd__opOr_Expression2: return "<expression_add> ~ || <expression2>";
		case Gr_Expression2__Expression3_Expression2Adds: return "<expression2> ~ <expression3> <expression2_adds>";
		case Gr_Expression2Adds__Expression2Add_Expression2Adds: return "<expression2_adds> ~ <expression2_add> <expression2_adds>";
		case Gr_Expression2Adds__epsilon: return "<expression2_adds> ~";
		case Gr_Expression2Add__opXor_Expression3: return "<expression2_add> ~ ^^ <expression3>";
		case Gr_Expression3__Expression4_Expression3Adds: return "<expression3> ~ <expression4> <expression3_adds>";
		case Gr_Expression3Adds__Expression3Add_Expression3Adds: return "<expression3_adds> ~ <expression3_add> <expression3_adds>";
		case Gr_Expression3Adds__epsilon: return "<expression3_adds> ~";
		case Gr_Expression3Add__opAnd_Expression4: return "<expression3_add> ~ && <expression4>";
		case Gr_Expression4__Expression5: return "<expression4> ~ <expression5>";
		case Gr_Expression4__opNot_Expression4: return "<expression4> ~ ! <expression4>";
		case Gr_Expression5__Expression6: return "<expression5> ~ <expression6>";
		case Gr_Expression5__Expression6_opLess_Expression6: return "<expression5> ~ <expression6> < <expression6>";
		case Gr_Expression5__Expression6_opGreat_Expression6: return "<expression5> ~ <expression6> > <expression6>";
		case Gr_Expression5__Expression6_opLessEq_Expression6: return "<expression5> ~ <expression6> <= <expression6>";
		case Gr_Expression5__Expression6_opGreatEq_Expression6: return "<expression5> ~ <expression6> >= <expression6>";
		case Gr_Expression5__Expression6_opEq_Expression6: return "<expression5> ~ <expression6> == <expression6>";
		case Gr_Expression5__Expression6_opNotEq_Expression6: return "<expression5> ~ <expression6> != <expression6>";
		case Gr_Expression6__Expression7_Expression6Adds: return "<expression6> ~ <expression7> <expression6_adds>";
		case Gr_Expression6Adds__Expression6Add_Expression6Adds: return "<expression6_adds> ~ <expression6_add> <expression6_adds>";
		case Gr_Expression6Adds__epsilon: return "<expression6_adds> ~";
		case Gr_Expression6Add__opAdd_Expression7: return "<expression6_add> ~ + <expression7>";
		case Gr_Expression6Add__opSub_Expression7: return "<expression6_add> ~ - <expression7>";
		case Gr_Expression7__Expression8_Expression7Adds: return "<expression7> ~ <expression8> <expression7_adds>";
		case Gr_Expression7Adds__Expression7Add_Expression7Adds: return "<expression7_adds> ~ <expression7_add> <expression7_adds>";
		case Gr_Expression7Adds__epsilon: return "<expression7_adds> ~";
		case Gr_Expression7Add__opMul_Expression8: return "<expression7_add> ~ * <expression8>";
		case Gr_Expression7Add__opDiv_Expression8: return "<expression7_add> ~ / <expression8>";
		case Gr_Expression7Add__opMod_Expression8: return "<expression7_add> ~ % <expression8>";
		case Gr_Expression8__Expression9: return "<expression8> ~ <expression9>";
		case Gr_Expression8__Expression9_opExp_Expression8: return "<expression8> ~ <expression9> ^ <expression8>";
		case Gr_Expression9__Value: return "<expression9> ~ <value>";
		case Gr_Expression9__opSub_Expression9: return "<expression9> ~ - <expression9>";
		case Gr_Expression9__opAdd_Expression9: return "<expression9> ~ + <expression9>";
		case Gr_Name__NAME_NameAdd: return "<name> ~ NAME <name_add>";
		case Gr_NameAdd__NamePeriodAdd_NameAdd: return "<name_add> ~ <name_period_add> <name_add>";
		case Gr_NameAdd__epsilon: return "<name_add> ~";
		case Gr_NamePeriodAdd__spPer_NAME: return "<name_period_add> ~ . NAME";
		case Gr_Value__LITERAL: return "<value> ~ LITERAL";
		case Gr_Value__null: return "<value> ~ null";
		case Gr_Value__new_DataType_ArrayDefinitionsSize_spLPar_Arguments_spRPar: return "<value> ~ new <data_type> <array_definitions_size> ( <arguments> )";
		case Gr_Value__new_DataType_ArrayDefinitionsSize_Initialisation: return "<value> ~ new <data_type> <array_definitions_size> <initialisation>";
		case Gr_Value__Name_instance_of_Name: return "<value> ~ <name> instance of <name>";
		case Gr_Value__NAME_spLPar_Arguments_spRPar: return "<value> ~ NAME ( <arguments> )";
		case Gr_Value__spLPar_Expression_spRPar: return "<value> ~ ( <expression> )";
		case Gr_Value__spLPar_DataType_spRPar_VariableValue: return "<value> ~ ( <data_type> ) <variable_value>";
		case Gr_Value__VariableValue: return "<value> ~ <variable_value>";
		case Gr_Value__VariableValue_spPer_NAME_spLPar_Arguments_spRPar: return "<value> ~ <variable_value> . NAME ( <arguments> )";
		case Gr_VariableValue__NameAmbiguous_ArrayDefinitionsSize_VariableValueAdd: return "<variable_value> ~ <name_ambiguous> <array_definitions_size> <variable_value_add>";
		case Gr_VariableValueAdd__PeriodVariableValue_VariableValueAdd: return "<variable_value_add> ~ <period_variable_value> <variable_value_add>";
		case Gr_VariableValueAdd__epsilon: return "<variable_value_add> ~";
		case Gr_PeriodVariableValue__spPer_VariableValue: return "<period_variable_value> ~ . <variable_value>";
		case Gr_NameAmbiguous__NAME_NameAddAmbiguous: return "<name_ambiguous> ~ NAME <name_add_ambiguous>";
		case Gr_NameAddAmbiguous__NamePeriodAdd_NameAddAmbiguous: return "<name_add_ambiguous> ~ <name_period_add> <name_add_ambiguous>";
		case Gr_NameAddAmbiguous__epsilon: return "<name_add_ambiguous> ~";
		case Gr_Initialisation__spLCBrac_InitialValues_spRCBrac: return "<initialisation> ~ { <initial_values> }";
		case Gr_Initialisation__epsilon: return "<initialisation> ~";
		case Gr_InitialValues__InitialValue_InitialValueAdd: return "<initial_values> ~ <initial_value> <initial_value_add>";
		case Gr_InitialValues__epsilon: return "<initial_values> ~";
		case Gr_InitialValueAdd__InitialValueComma_InitialValueAdd: return "<initial_value_add> ~ <initial_value_comma> <initial_value_add>";
		case Gr_InitialValueAdd__epsilon: return "<initial_value_add> ~";
		case Gr_InitialValue__spLCBrac_InitialValues_spRCBrac: return "<initial_value> ~ { <initial_values> }";
		case Gr_InitialValue__Expression: return "<initial_value> ~ <expression>";
		case Gr_InitialValueComma__spComma_InitialValue: return "<initial_value_comma> ~ , <initial_value>";
		case Gr_ArrayDefinitionsSize__ArrayDefinitionSize_ArrayDefinitionsSize: return "<array_definitions_size> ~ <array_definition_size> <array_definitions_size>";
		case Gr_ArrayDefinitionsSize__epsilon: return "<array_definitions_size> ~";
		case Gr_ArrayDefinitionSize__spLSBrac_Expression_spRSBrac: return "<array_definition_size> ~ [ <expression> ]";
		default: return "UNKNOWN PRODUCTION";
	}
}
#endif
